package com.ruoyi.school.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.school.domain.PacClassTable;
import com.ruoyi.school.service.PacClassTableService;
import com.ruoyi.school.mapper.PacClassTableMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author jeremylin
* @description 针对表【pac_class_table(班级表)】的数据库操作Service实现
* @createDate 2025-11-04 05:15:39
*/
@Service
public class PacClassTableServiceImpl extends ServiceImpl<PacClassTableMapper, PacClassTable>
    implements PacClassTableService{

    @Override
    public List<PacClassTable> getList(PacClassTable pacClass) {
        List<PacClassTable> list = lambdaQuery().list();
        return list;
    }

    @Override
    public PacClassTable getDetails(PacClassTable pacClass) {
        if (pacClass.getId() == null) {
            throw new RuntimeException("id不能为空");
        }
        PacClassTable one = lambdaQuery().eq(PacClassTable::getId, pacClass.getId()).one();
        return one;
    }

    @Override
    public boolean add(PacClassTable pacClass) {
        if (save(pacClass)) {
            return true;
        }
        return false;
    }

    @Override
    public boolean edit(PacClassTable pacClass) {
        if (pacClass.getId() == null) {
            throw new RuntimeException("id不能为空");
        }
        if (updateById(pacClass)) {
            return true;
        }
        return false;
    }

    @Override
    public boolean delete(PacClassTable pacClass) {
        if (pacClass.getId() == null) {
            throw new RuntimeException("id不能为空");
        }
        if (removeById(pacClass)) {
            return true;
        }
        return false;
    }

    @Override
    public List<PacClassTable> getAllList(PacClassTable pacClass) {
        List<PacClassTable> list = lambdaQuery().list();
        return list;
    }

    @Override
    public List<PacClassTable> getListByCollegeAndDept(PacClassTable pacClass) {
        List<PacClassTable> list = lambdaQuery().eq(PacClassTable::getCollegeId, pacClass.getCollegeId())
                .eq(PacClassTable::getDeptId, pacClass.getDeptId())
                .list();
        return list;
    }
}




